<?php
class m_kelas_materi extends CI_Model
{
	public $table = 'kelas_materi';
	
	/* function get_kl_id($id){
		$this->db->select('kl_id');
		$this->db->from($this->table);
		$this->db->where('uj_id', $id);

		$query = $this->db->get();
		
		return $query->result_array();		
	}
	
	function get_ujian_by_kelas($nis, $uj_id = null){
		$this->db->select('ujian.*, mata_pelajaran.*');
		$this->db->from($this->table);
		$this->db->join('ujian', 'ujian.uj_id = kelas_ujian.uj_id', 'inner');
		$this->db->join('siswa', 'siswa.kl_id = kelas_ujian.kl_id', 'inner');
		$this->db->join('mata_pelajaran', 'mata_pelajaran.mp_id = ujian.mp_id', 'inner');
		if($uj_id)$this->db->where_not_in('ujian.uj_id', $uj_id);
		$this->db->where('siswa.sw_nis', $nis);

		$query = $this->db->get();
		
		return $query->result();
	}
	
	function get_ujian_with_id($id){
		$this->db->select('uj_id');
		$this->db->from('nilai');
		$this->db->where('sw_id', $id);

		$rows = $this->db->get()->result();
		$result = array();
		foreach ($rows as $row){
			$result[] = $row->uj_id;
		}
		
		return $result;		
	} */
	
	function insert($value){
		return $this->db->insert($this->table, $value);
	}
	
	function update($value, $where){
		return $this->db->update($this->table, $value, $where);
	}
	
	function delete($where){
		return $this->db->delete($this->table, $where);
	}
}
?>